﻿using System;
using System.Web.UI.WebControls;
using WorkOrder.Business;

namespace WorkOrder
{
    public partial class main_timely : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                TaskReport tr = new TaskReport();
                int a, b, _e, f, g, h, i;
                a = tr.getSum(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + "1",
                              DateTime.Now.Date.ToShortDateString());
                b = tr.getCountTimeOut(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + "1",
                                       DateTime.Now.Date.ToShortDateString());
                _e = tr.getConfirmOnLine();
                f = tr.getConfirmOnlineTimeOut();
                g = tr.getConfirmOnlineAlarm30();
                h = tr.getConfirmOnlineAlarm5();
                i = tr.getConfirmOnlineAlarm10();
                LabelA.Text = a.ToString();
                LabelB.Text = b.ToString();
                if (a != 0) lblC.Text = Math.Round(Math.Round((decimal)(a - b) / (decimal)a, 4) * 100, 2).ToString();
                lblD.Text = tr.getOnline().ToString();
                LabelE.Text = _e.ToString();
                LabelF.Text = f.ToString();
                LabelG.Text = g.ToString();
                LabelH.Text = h.ToString();
                LabelI.Text = i.ToString();
                GridView1.DataSource = tr.getConfirmOnlineTimeOutList();
                GridView1.DataBind();
            }
        }

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            TaskReport tr = new TaskReport();
            int a, b, _e, f, g, h, i;
            a = tr.getSum(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + "1",
                          DateTime.Now.Date.ToShortDateString());
            b = tr.getCountTimeOut(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + "1",
                                   DateTime.Now.Date.ToShortDateString());
            _e = tr.getConfirmOnLine();
            f = tr.getConfirmOnlineTimeOut();
            g = tr.getConfirmOnlineAlarm30();
            h = tr.getConfirmOnlineAlarm5();
            i = tr.getConfirmOnlineAlarm10();
            LabelA.Text = a.ToString();
            LabelB.Text = b.ToString();
            if (a!=0) lblC.Text = Math.Round(Math.Round((decimal)(a - b) / (decimal)a, 4) * 100, 2).ToString();
            lblD.Text = tr.getOnline().ToString();
            LabelE.Text = _e.ToString();
            LabelF.Text = f.ToString();
            LabelG.Text = g.ToString();
            LabelH.Text = h.ToString();
            LabelI.Text = i.ToString();

            GridView1.DataSource = tr.getConfirmOnlineTimeOutList();
            GridView1.DataBind();
        }

        #region 处理光标行颜色事件
        protected void gvReport_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex >= 0)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor,this.style.background='#ffe3a0'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            }
            try
            {
                e.Row.Cells[1].Attributes.Add("title", e.Row.Cells[1].Text);
                e.Row.Cells[1].Text = e.Row.Cells[1].Text.Substring(0, 12) + "...";
                e.Row.ForeColor = System.Drawing.Color.Red;
            }
            catch { }
        }
        #endregion
    }
}